﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace LibraryManager
{
    public partial class FindUserDetailForm : Form
    {
        private String _id;
        public String Id
        {
            get { return _id; }
            set { _id = value; }
        }

        public FindUserDetailForm()
        {
            InitializeComponent();
        }

        private void FindUserDetailForm_Load(object sender, EventArgs e)
        {
            string str = System.Configuration.ConfigurationManager.ConnectionStrings["library"].ConnectionString;
            string sql = "select * from users where uId='" + Id + "'";
            using (SqlConnection conn = new SqlConnection(str))
            {
                SqlCommand cmd = new SqlCommand(sql, conn);
                conn.Open();
                // ExecuteReader()返回一个Datareader对象，这个对象的内容就是与命令匹配的所有行
                using (SqlDataReader r = cmd.ExecuteReader())
                {
                    r.Read();
                    IdLab.Text = r.GetString(0);
                    nameLab.Text = r.GetString(2);
                    phoneLab.Text = r.GetString(4);
                    GenderLab.Text = r.GetString(3);
                    if (r.GetString(5).Equals("1"))
                    {
                        UserStatusLab.Text = "被锁定,请尽快联系管理员办理解锁";
                    }
                    else
                    {
                        UserStatusLab.Text = "正常";
                    }
                }
                cmd.Dispose();
            }
        }
    }
}
